/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ondrej
 */
@Entity
@Table(name = "employee")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
    @NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.id = :id"),
    @NamedQuery(name = "Employee.findBySocialSecNr", query = "SELECT e FROM Employee e WHERE e.socialSecNr = :socialSecNr"),
    @NamedQuery(name = "Employee.findByEnterDate", query = "SELECT e FROM Employee e WHERE e.enterDate = :enterDate"),
    @NamedQuery(name = "Employee.findByLeaveDate", query = "SELECT e FROM Employee e WHERE e.leaveDate = :leaveDate"),
    @NamedQuery(name = "Employee.findByCurrentIncome", query = "SELECT e FROM Employee e WHERE e.currentIncome = :currentIncome"),
    @NamedQuery(name = "Employee.findByEducation", query = "SELECT e FROM Employee e WHERE e.education = :education"),
    @NamedQuery(name = "Employee.findByHourRate", query = "SELECT e FROM Employee e WHERE e.hourRate = :hourRate")})
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "social_sec_nr")
    private Integer socialSecNr;
    @Column(name = "enter_date")
    private Integer enterDate;
    @Column(name = "leave_date")
    private Integer leaveDate;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "current_income")
    private BigDecimal currentIncome;
    @Size(max = 200)
    @Column(name = "education")
    private String education;
    @Column(name = "hour_rate")
    private BigDecimal hourRate;
    @OneToMany(mappedBy = "eMPLOYEEid")
    private Collection<PersonnelManagement> personnelManagementCollection;
    @OneToMany(mappedBy = "eMPLOYEEid")
    private Collection<Project> projectCollection;
    @OneToMany(mappedBy = "eMPLOYEEid")
    private Collection<WorkingBlock> workingBlockCollection;
    @JoinColumn(name = "PERSON_id", referencedColumnName = "id")
    @ManyToOne
    private Person pERSONid;
    @JoinColumn(name = "EMPLOYEE_STATUS_id", referencedColumnName = "id")
    @ManyToOne
    private EmployeeStatus eMPLOYEESTATUSid;
    @JoinColumn(name = "CONTRACT_TYPE_id", referencedColumnName = "id")
    @ManyToOne
    private ContractType cONTRACTTYPEid;

    public Employee() {
    }

    public Employee(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getSocialSecNr() {
        return socialSecNr;
    }

    public void setSocialSecNr(Integer socialSecNr) {
        this.socialSecNr = socialSecNr;
    }

    public Integer getEnterDate() {
        return enterDate;
    }

    public void setEnterDate(Integer enterDate) {
        this.enterDate = enterDate;
    }

    public Integer getLeaveDate() {
        return leaveDate;
    }

    public void setLeaveDate(Integer leaveDate) {
        this.leaveDate = leaveDate;
    }

    public BigDecimal getCurrentIncome() {
        return currentIncome;
    }

    public void setCurrentIncome(BigDecimal currentIncome) {
        this.currentIncome = currentIncome;
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education;
    }

    public BigDecimal getHourRate() {
        return hourRate;
    }

    public void setHourRate(BigDecimal hourRate) {
        this.hourRate = hourRate;
    }

    @XmlTransient
    public Collection<PersonnelManagement> getPersonnelManagementCollection() {
        return personnelManagementCollection;
    }

    public void setPersonnelManagementCollection(Collection<PersonnelManagement> personnelManagementCollection) {
        this.personnelManagementCollection = personnelManagementCollection;
    }

    @XmlTransient
    public Collection<Project> getProjectCollection() {
        return projectCollection;
    }

    public void setProjectCollection(Collection<Project> projectCollection) {
        this.projectCollection = projectCollection;
    }

    @XmlTransient
    public Collection<WorkingBlock> getWorkingBlockCollection() {
        return workingBlockCollection;
    }

    public void setWorkingBlockCollection(Collection<WorkingBlock> workingBlockCollection) {
        this.workingBlockCollection = workingBlockCollection;
    }

    public Person getPERSONid() {
        return pERSONid;
    }

    public void setPERSONid(Person pERSONid) {
        this.pERSONid = pERSONid;
    }

    public EmployeeStatus getEMPLOYEESTATUSid() {
        return eMPLOYEESTATUSid;
    }

    public void setEMPLOYEESTATUSid(EmployeeStatus eMPLOYEESTATUSid) {
        this.eMPLOYEESTATUSid = eMPLOYEESTATUSid;
    }

    public ContractType getCONTRACTTYPEid() {
        return cONTRACTTYPEid;
    }

    public void setCONTRACTTYPEid(ContractType cONTRACTTYPEid) {
        this.cONTRACTTYPEid = cONTRACTTYPEid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employee)) {
            return false;
        }
        Employee other = (Employee) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Employee[ id=" + id + " ]";
    }
    
}
